class Solution {
    private int target;
    private int count;
    public int findTargetSumWays(int[] nums, int _target) {
        target = _target;
        dfs(nums, 0, 0);
        return count;
    }
    private void dfs(int[] nums, int tmp, int index) {
        if(index == nums.length && tmp == target) {
            count++;
            return;
        }
        if(index == nums.length) {
            return;
        }
        tmp = tmp + nums[index];
        dfs(nums, tmp, index+1);
        tmp = tmp - nums[index];

        tmp = tmp - nums[index];
        dfs(nums, tmp, index+1);
        tmp = tmp + nums[index];
    }
}